<template>
  <view class="video_tab">
    <view class="video_tab_title">
      <view class="video_tab_inner">
        <uni-segmented-control
          :current="current"
          :values="items.map((item) => item.title)"
          @clickItem="onClickItem"
          style-type="text"
          active-color="#42a5f5"
        ></uni-segmented-control>
      </view>
      <view class="iconfont iconsearch"></view>
    </view>
    <view class="video_tab_content">
      <view v-if="current < 4">
        <video-main :urlObject="{url: items[current].url,params: items[current].params}"></video-main>
      </view>
      <view v-if="current === 4">
        <video-category></video-category>
      </view>
    </view>
  </view>
</template>

<script>
import { uniSegmentedControl } from "@dcloudio/uni-ui"; // 导入 uni-ui 的分段器
import videoMain from "./video-main";
import videoCategory from "./video-category";
export default {
  /* 数据源 */
  data() {
    return {
      items: [
        {
          title: "推荐",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/featured",
          params: { limit: 30, skip: 0, order: "hot" },
        },
        { 
          title: "娱乐",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/category/59b25abbe7bce76bc834198a",
          params: { limit: 30, skip: 0, order: "hot" },
        },
        {
          title: "最新",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/videowp",
          params: { limit: 30, skip: 0, order: "new" },
        },
        {
          title: "热门",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/videowp",
          params: { limit: 30, skip: 0, order: "hot" },
        },
        {
          title: "分类",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/category",
          params: {},
        },
      ],
      current: 0,
    };
  },
  /* 方法集合 */
  methods: {
    onClickItem(e) {
      // console.log("debug => ",e)
      if (this.current !== e.currentIndex) {
        this.current = e.currentIndex;
      }
    },
  },
  /* 注册组件 */
  components: {
    uniSegmentedControl,
    videoMain,
    videoCategory,
  },
};
</script>

<style lang="scss">
.video_tab {
  .video_tab_title {
    position: relative; // relative 相对定位
    .video_tab_inner {
      width: 60%;
      margin: 0 auto; // 水平居中
    }
    .iconsearch {
      position: absolute; // absolute 绝对定位
      top: 50%;
      transform: translateY(-50%);
      right: 5%;
    }
  }
  .video_tab_content {
  }
}
</style>